package com.jr.service.impl;

import com.jr.entity.Post;
import com.jr.mapper.PostMapper;
import com.jr.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class PostServiceImpl implements PostService {
    @Autowired
    private PostMapper postMapper;

    @Override

    public Post selectByPid(Integer pid) {
        ArrayList<Post> posts = postMapper.SelectPostByPid(pid);
        if (posts.size()>0){
            return posts.get(0);
        }else {

        return null;
        }
    }

    @Override
    public ArrayList<Post> SelectPostsByPid(Integer eid) {
        ArrayList<Post> postsByPid = postMapper.SelectPostsByPid(eid);
        return postsByPid;



    }

    @Override
    public ArrayList<Post> findAllPosts(Post post) {
        return postMapper.findAllPost(post);
    }
}

